<?php
/**
 * Created by PhpStorm.
 * User: liuqi.
 * Date: 2017/10/26 13:25.
 */

namespace home\Controller;


class ComplaintController extends ApibaseController
{

    function __construct()
    {
        parent::__construct();
    }

    /**
     *患者投诉列表
     */
    public function patientComplaint()
    {
        $page    = I('get.page', 1);
        $perpage = I('perpage', 10);
        $url     = [];
        $model   = M('ComplaintInfo')->where(['complaint_type' => 0]);
        $getData = $model->page($page, $perpage)->select();
        foreach ($getData as $k => $v) {
            $getData['complaint_name']   = M('PatientInfo')->where(['patient_id' => $v['complaint_user']])->getField('patient_name');
            $getData['complainted_name'] = M('PatientInfo')->where(['patient_id' => $v['complainted_user']])->getField('patient_name');
        }
        $this->assign('page', setPage($model->count(), $perpage, $page, '?' . http_build_query($url)));
        $this->assign('getData', $getData);
        $this->display();
    }

    /**
     *院内投诉列表
     */
    public function hosComplaint()
    {
        $page    = I('get.page', 1);
        $perpage = I('perpage', 10);
        $url     = [];
        $model   = M('Complaint')->where(['complaint_type' => 1]);
        $getData = $model->page($page, $perpage)->select();
        $this->assign('page', setPage($model->count(), $perpage, $page, '?' . http_build_query($url)));
        $this->assign('getData', $getData);
        $this->display();
    }
}
